package com.summer.data.jql.concept.other;

import com.summer.data.Jsql;
import com.summer.data.dialect.Dialect;
import com.summer.data.jql.Context;
import com.summer.data.jql.behavior.SelectAble;
import com.summer.data.jql.behavior.TableAble;

/**
 * @author 345480567@qq.com
 */
public class Star implements SelectAble {

    TableAble obj;

    public Star(TableAble abstractTable) {
        this.obj = abstractTable;
    }

    @Override
    public Jsql toSelectJsql(Context ctx, Dialect dialect) {
        String alias = ctx.getAlias(obj);
        alias = alias == null || alias.isEmpty() ? obj.getTableName() : alias;
        return Jsql.format("%s.*", alias);
    }

}
